<?php
/**
 * sina用户表数据操作层
 * @author yangchao
 */

class db_love_bless extends db_base {
    
	var $table_name = "love_bless";
	
	function db_user_info()
	{
		parent::db_base();
	}
	
	/**
	 * 前台取用户信息
	 * @param $uid
	 */
	function get_list_by_request_id($request_id,$p=1,$pcount=10)
	{
		$mc = mem_cache::get_instance();
		$key = CACHE_PREFIX_USER_ITEM;
		$cache = $mc->get($key);
		if ($cache === false)
		{
			$content = $this->get_alllist($this->table_name,$p,$pcount,"create_time desc","request_id='{$request_id}' and status=1");
			// 保存MC
			$mc->set($key, serialize($content), 0, 300);
		}
		else
		{
			$content = unserialize($cache);
		}
		
		return $content;
		
	}
	/**
	 * 前台取用户信息
	 * @param $uid
	 */
	function get_count_by_request_id($request_id)
	{
		$mc = mem_cache::get_instance();
		$key = CACHE_PREFIX_USER_ITEM."get_count_by_request_id-{$request_id}";
		$cache = $mc->get($key);
		if ($cache === false)
		{
			$content = $this->get_listcount($this->table_name,"request_id='{$request_id}' and status=1");
			// 保存MC
			$mc->set($key, serialize($content), 0, 300);
		}
		else
		{
			$content = unserialize($cache);
		}
		
		return $content;
		
	}
	
	/**
	 * 插入请求数据
	 */
	function insert_love_bless($bless_uid,$request_id,$content)
	{
		// 插入数据
		$ary = array();
		$ary["bless_uid"] = $bless_uid;
		$ary["request_id"] = $request_id;
		$ary["content"] = $content;
		$ary["create_time"] = Date::get_date_time();
		$ary["status"] = 1;
		
		$ret = $this->insert($this->table_name, $ary);
		if ($ret)
		{
			/*$memcache = mem_cache::get_instance();
			$memcache->delete($key);*/
		}
		else
		{
			return false;
		}


		return $this->get_lastinsertid();
	}
	

}


?>
